package br.com.simora.musica;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.view.Results;
import br.com.simora.controller.BasicController;

@Controller
public class MusicaController extends BasicController {
	@Inject private MusicaDAO musicaDAO;

	public MusicaController(){}
	
	@PostConstruct
    public void init(){
        injetaUsuario();
    }
	
	@Post
	public void gravar(Musica musica){
		Musica temp = (Musica) musicaDAO.find(Musica.class, musica.getId());
		temp.setNome(musica.getNome());
		musicaDAO.update(temp);
		result.use(Results.json()).from(true, "retorno").serialize();
	}

	@Override
	protected void redirect() {}
}
